﻿Namespace Localization
    <System.Windows.Markup.MarkupExtensionReturnType(GetType(System.Uri))> _
    Public Class UriExtension
        Inherits StringExtension

        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal key As String)
            MyBase.New(key)
        End Sub

        Public Overrides Function ProvideValue(ByVal serviceProvider As System.IServiceProvider) As Object
            Dim result As String = MyBase.ProvideValue(serviceProvider)
            If result.StartsWith("[") Then
                Return Nothing
            Else
                Return New Uri(result, UriKind.Relative)
            End If
        End Function
    End Class
End Namespace
